package pl.PawelAndAlicja.badugiproject.main.Cards;

import java.util.ArrayList;
import java.util.Random;

/**
 * Created by Pawel on 2014-11-16.
 */
public class HandMasterMain extends ClientDeck {

    public HandMasterMain(FlyweightFactoryCard factoryCard) {
        super(factoryCard);
        this.createDeck();

        cardTypes = new ArrayList<String>();
        cardNames = new ArrayList<String>();

        for (int i = 0; i < types.length ; i++) {
            cardTypes.add(types[i]);
        }

        for (int i = 0; i < names.length ; i++) {
            cardNames.add(names[i]);
        }

    }

    public void checkMasterHandWithPlayerHand() {

    }

    public ClientDeck getHandFromMaster() {
        Random gen = new Random();

        int valueOfCardTypes;
        int valueOfCardName;
        ClientDeck hand = new ClientDeck( new FlyweightFactoryCard());

        for (int i = 0; i < AMOUNT_CARDS_IN_HAND; i++) {
            valueOfCardTypes = gen.nextInt(cardTypes.size());
            valueOfCardName = gen.nextInt(cardNames.size());

            //Tworzenie tymczasowego decka z ktorego potem usuwamy karty w głownym decku by było zaktualizowane
            hand.createCard(cardTypes.get(valueOfCardTypes), cardNames.get(valueOfCardName));
            this.removeCard(cardTypes.get(valueOfCardTypes), cardNames.get(valueOfCardName));
        }

        return hand;
    }

    public ClientDeck changeCardsInHand(int amountCards) {
        ClientDeck hand = new ClientDeck( new FlyweightFactoryCard());

        return hand;
    }

    public static final int AMOUNT_CARDS_IN_HAND = 4;


    private String types[] = {"Spade","Club","Diamond","Heart"};
    private String names []= {"King", "Queen", "Jack", "10", "9", "8", "7", "6", "5", "4", "3", "2", "Ace"};

    private ArrayList<String> cardTypes;
    private ArrayList<String> cardNames;

}
